import request from "@/plugins/axios";

export function getRoleList(data: Partial<Role>) {
    return request.post<Role[]>('/api/role/list', data)
}

export function createRole(data: Role) {
    return request.post('/api/role', data)
}

export function updateRole(data: Role) {
    return request.put('/api/role', data)
}

export function deleteRole(id: number) {
    return request.delete(`/api/role/${id}`)
}

export function getRole(id: number) {
    return request.get<Role>(`/api/role/${id}`)
}

export function getMenuIdsByRoleId(id: number) {
    return request.get<number[]>(`/api/role/role_menu/${id}`)
}

export function saveRoleMenu(data: {roleId: number, menuIds: number[]}) {
    return request.post(`/api/role/role_menu`, data)
}
